<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<script type="text/javascript" src="js/jquery-2.1.1.js"></script>
</head>
<body>
<h2>Hello World!</h2>
<form action="user/upload" method="post" enctype="multipart/form-data">
文件<input type="file" name="file">
<input type="submit">
</form>
<hr>
<h3>输什么查什么</h3>
<form action="user/query" method="post">
<input name="id">
<input name="name">
<input name="password">
<input type="submit">
</form>
<hr>
<h3>add</h3>
	<form method="post" id="user_add">
		  roleId
		  <input type="text" name="roleId" /> 
		  name 
		  <input type="text" name="name" /> 
		  password 
		  <input type="password"  name="password" /> 
		  <input type="button" value="提交" onclick="add()" />
	</form>
<h3>del</h3>
	<form method="post" id="user_del">
		      编号
		  <input type="text" name="id" /> 
		  <input type="button" value="提交" onclick="del()" />
	</form>
<h3>update</h3>
	<form method="post" id="user_update">
	  	      编号
		  <input type="text" name="id" /> 
		  name 
		  <input type="text" name="name" /> 
		  password
		  <input type="password" name="password" /> 
		  <input type="button" value="提交" onclick="update()" />
	</form>
<h3>query</h3>
	<form method="post" id="user_query">
		      编号
		  <input type="text" name="id" /> 
	       num
	      <input type="text"  name="num"/><br>
	       pageCount 
		  <input type="text"  name="pageCount"/><br>	  
		  <input type="button" value="提交" onclick="query()" />
	</form>
	
<h3>天气</h3>
	<form method="get" id="weather">
		   key
		  <input type="text" name="key" /> 
	       city
	      <input type="text"  name="city"/><br>
		  <input type="button" value="提交" onclick="weather()" />
	</form>	
<h3>查查</h3>
<form  id="getAll"  method="post" action="http://localhost:8080/ssm/user/getAll">
	<input type="submit">
  <!-- <input type="button" value="提交" onclick="getAll()" /> -->
</form>	

<hr>
 <table>
<tr>

<td>后一页</td>
<td>编号</td>
<td>角色</td>
<td>姓名</td>
<td>密码</td>
<td>时间</td>
<td>前一页</td>
</tr>
<c:forEach   var="user" items="${Page}" >
<tr>
<td>${user.nextPage}</td>
<td>${user.list.id}</td>
<td>${user.list.roleId}</td>
<td>${user.list.name}</td> 
<td>${user.list.password}</td>
<td>${user.list.createTime}</td>
<td>${user.prePage}</td>
</tr>
</c:forEach> 



</table>
<div id="pace"></div>

</body>

<script type="text/javascript">

function login(){
	  jQuery.ajax({
		  	url : "http://restapi.amap.com/v3/weather/login",
		  	data : jQuery("#weather").serialize(),
		  	type: "post",
		  	success : function (res) {
		  		if (res != null) {
		  			
		  			console.log(res)
		  			
		  		} else {
		  			alert("无数据");
		  		}
		  	
		  	},
		  	fail : function(res) {
		  		alert("系统错误！");
		  	}
		  });
}

function weather(){
	  jQuery.ajax({
		  	url : "http://restapi.amap.com/v3/weather/weatherInfo",
		  	data : jQuery("#weather").serialize(),
		  	type: "post",
		  	success : function (res) {
		  		if (res != null) {
		  			
		  			console.log(res)
		  			
		  		} else {
		  			alert("无数据");
		  		}
		  	
		  	},
		  	fail : function(res) {
		  		alert("系统错误！");
		  	}
		  });
}

function getAll(){
	  jQuery.ajax({
		  	url : "http://localhost:8080/ssm/user/getAll",
		  	data : jQuery("#getAll").serialize(),
		  	type: "post",
		  	success : function (res) {
		  		if (res != null) {
		  		alert(json.parse(res))
		  			console.log(res)
		  			
		  		} else {
		  			alert("无数据");
		  		}
		  	
		  	},
		  	fail : function(res) {
		  		alert("系统错误！");
		  	}
		  });
}


 function add(){
 	  jQuery.ajax({
 		  	url : "<%=request.getContextPath()%>/user/add",
 		  	data : jQuery("#user_add").serialize(),
 		  	type: "post",
 		  	success : function (res) {
 		  		if (res != null) {
 		  			
 		  			console.log(res)
 		  			
 		  		} else {
 		  			alert("无数据");
 		  		}
 		  	
 		  	},
 		  	fail : function(res) {
 		  		alert("系统错误！");
 		  	}
 		  });
 }
 
 function del(){
 	  jQuery.ajax({
 		  	url : "<%=request.getContextPath()%>/user/delete",
 		  	data : jQuery("#user_del").serialize(),
 		  	type: "post",
 		  	success : function (res) {
 		  		if (res != null) {
 		  			
 		  			console.log(res)
 		  			
 		  		} else {
 		  			alert("无数据");
 		  		}
 		  	
 		  	},
 		  	fail : function(res) {
 		  		alert("系统错误！");
 		  	}
 		  });
 }
 
 function update(){
 	  jQuery.ajax({
 		  	url : "<%=request.getContextPath()%>/user/update",
 		  	data : jQuery("#user_update").serialize(),
 		  	type: "post",
 		  	success : function (res) {
 		  		if (res != null) {
 		  			
 		  			console.log(res)
 		  			
 		  		} else {
 		  			alert("无数据");
 		  		}
 		  	
 		  	},
 		  	fail : function(res) {
 		  		alert("系统错误！");
 		  	}
 		  });
 }
 
 function query(){
 	  jQuery.ajax({
 		  	url : "<%=request.getContextPath()%>/user/getQuery",
 		  	data : jQuery("#user_query").serialize(),
 		  	type: "post",
 		  	success : function (res) {
 		  		if (res != null) {
 		  			
 		  			console.log(res)
 		  			
 		  		} else {
 		  			alert("无数据");
 		  		}
 		  	
 		  	},
 		  	fail : function(res) {
 		  		alert("系统错误！");
 		  	}
 		  });
 }
</script> 

</html>